package com.adv.ems.manager.impl;

import com.adv.ems.model.dto.TablePartitionInfoDTO;
import com.adv.ems.db.mapper.SystemConfigMapper;
import com.adv.ems.db.entity.SystemConfigDO;
import com.adv.ems.manager.SystemConfigManager;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;

@Service
public class SystemConfigManagerImpl extends BaseManagerImpl<SystemConfigMapper, SystemConfigDO> implements SystemConfigManager {
    @Override
    public List<SystemConfigDO> selectByType(String type) {
        return getAllMap().values().stream().filter(c -> type.equals(c.getType())).collect(Collectors.toList());
    }

    @Override
    public List<String> getTableExistedPartitions(String table) {
        return baseMapper.getTableExistedPartitions(table);
    }

    @Override
    public void addPartitions(String table, List<TablePartitionInfoDTO.PartitionKey> toAdd) {
        baseMapper.addPartitions(table, toAdd);
    }

    @Override
    public void dropPartitions(String table, List<String> toDel) {
        baseMapper.dropPartitions(table, toDel);
    }

    @Override
    public void saveData(SystemConfigDO record) {
        save(record);
    }

    @Override
    public void updateDataById(SystemConfigDO entity) {
        super.updateById(entity);
    }
}
